import json
import pytest
import requests
from jsonpath import jsonpath

from 接口测试.tools.read_Excel import read_data
from 接口测试.tools.read_pathlib import exc_path
from 接口测试.tools.handle_assert import handle_assert

prodinfo_cartcase = read_data(exc_path=exc_path,sheetname="商品详情页")


@pytest.mark.parametrize("data",prodinfo_cartcase)
def test03_prod_info(data):
    prod_info_url = data["接口地址"]
    prod_info_param = json.loads(data["请求参数"])
    prod_info_res = requests.request(method="get",url=prod_info_url,params=prod_info_param)
    skuid = jsonpath(prod_info_res.json(),"$..skuId")[0]
    handle_assert(prod_info_res,data["预期结果"])
    return skuid